<template>
  <div v-if="props.labelName" class="tag">
    <div v-for="(item, index) in state.labelName" :key="index">
      <el-tag class="explainTag">{{ item }} </el-tag>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, defineProps, onMounted, getCurrentInstance, watch } from 'vue'
const { proxy }: any = getCurrentInstance()
const props = defineProps({
  labelName: {
    type: String,
  },
})

const state = reactive({
  labelName: [],
})
onMounted(() => {
  setTimeout(() => {
    if (props.labelName) {
      state.labelName = props.labelName.split(',')
    }
  }, 300)
})
watch(
  () => props.labelName,
  () => {
    if (props.labelName) {
      state.labelName = props.labelName.split(',')
    }
  }
)
</script>

<style lang="scss" scoped>
.tag {
  display: flex;
  margin: 10px 0;
  .explainTag {
    margin-right: 8px;
  }
}
</style>
